var t = getApp();

Page({
    data: {
        isShowTab: !1,
        activeName: 0,
        attentionList: [],
        fanList: [],
        isdelete: !1,
        avtiveUid: null,
        avtiveIndex: -1,
        page: 1,
        isLoadMore: !0,
        total_page: 0
    },
    onLoad: function(t) {
        this.setData({
            uid: t.uid,
            activeName: t.actived,
            active: 2 == t.actived ? 0 : 1,
            isShowTab: !0
        }), this.getList();
    },
    onReady: function() {},
    onShow: function() {},
    getList: function() {
        var a = this, e = {};
        1 == this.data.activeName ? (e.userType = 1, e.page = 1, e.member = this.data.uid) : (e.userType = 2, 
        e.page = 1, e.member = this.data.uid);
        var i = t.getNetAddresss("plugin.micro-communities.api.user.getFollowFans");
        t._getNetWork({
            url: i,
            data: e,
            success: function(t) {
                var e = t.data;
                1 === e.result ? (a.setData({
                    isLoadMore: !0,
                    total_page: e.data.last_page
                }), 1 == a.data.activeName ? a.setData({
                    fanList: e.data.data
                }) : a.setData({
                    attentionList: e.data.data
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    cancelLook: function(a) {
        var e = a.currentTarget.dataset.uid, i = this;
        wx.showModal({
            title: "提示",
            content: "确定取消关注对方",
            success: function(a) {
                if (a.confirm) {
                    var o = t.getNetAddresss("plugin.micro-communities.api.user.delFollow"), s = {
                        uid: e
                    };
                    t._getNetWork({
                        url: o,
                        data: s,
                        success: function(t) {
                            var a = t.data;
                            1 === a.result ? (wx.showToast({
                                title: a.msg,
                                icon: "none",
                                duration: 1500
                            }), i.setData({
                                attentionList: i.data.attentionList
                            })) : wx.showToast({
                                title: a.msg,
                                icon: "none",
                                duration: 1500
                            });
                        },
                        fail: function(t) {
                            console.log(t);
                        }
                    }), console.log("用户点击确定");
                } else a.cancel && console.log("用户点击取消");
            }
        });
    },
    toMember: function(t) {
        var a = t.currentTarget.dataset.uid;
        wx.navigateTo({
            url: "/packageC/micro_communities/microhomepage/microhomepage?micuid=" + a
        });
    },
    deleteFan: function() {
        var a = this;
        wx.showModal({
            title: "提示",
            content: "对方将不再关注你，且不会收到通知，你也不会被推荐给对方",
            success: function(e) {
                if (e.confirm) {
                    var i = t.getNetAddresss("plugin.micro-communities.api.user.delFans"), o = {
                        fid: a.data.avtiveUid
                    };
                    t._getNetWork({
                        url: i,
                        data: o,
                        success: function(t) {
                            var e = t.data;
                            1 === e.result ? (wx.showToast({
                                title: e.msg,
                                icon: "none",
                                duration: 1500
                            }), a.setData({
                                fanList: a.data.fanList,
                                isdelete: !1
                            })) : (a.setData({
                                isdelete: !1
                            }), wx.showToast({
                                title: e.msg,
                                icon: "none",
                                duration: 1500
                            }));
                        },
                        fail: function(t) {
                            console.log(t);
                        }
                    }), console.log("用户点击确定");
                } else e.cancel && console.log("用户点击取消");
            }
        });
    },
    lookUser: function(a) {
        var e = a.currentTarget.dataset.uid, i = t.getNetAddresss("plugin.micro-communities.api.user.addFollow"), o = {
            user_id: e
        };
        t._getNetWork({
            url: i,
            data: o,
            success: function(t) {
                var a = t.data;
                a.result, wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    showDelete: function(t) {
        var a = t.currentTarget.dataset.uid, e = t.currentTarget.dataset.index;
        this.setData({
            isdelete: !0,
            avtiveUid: a,
            avtiveIndex: e
        });
    },
    handleClick: function(t) {
        var a = t.detail.index;
        "0" == String(a) ? this.data.activeName = 2 : this.data.activeName = 1, this.setData({
            page: 1
        }), this.getList();
    },
    isCoverLayer: function() {
        this.setData({
            isdelete: !1
        });
    },
    getMoreData: function() {
        console.log(this.data.activeName);
        var a = this;
        if (a.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            a.setData({
                page: this.data.page + 1
            });
            var e = [];
            1 == a.data.activeName ? (e.userType = 1, e.page = a.data.page, e.member = this.data.uid) : (e.userType = 2, 
            e.page = a.data.page, e.member = this.data.uid);
            var i = t.getNetAddresss("plugin.micro-communities.api.user.getFollowFans");
            t._getNetWork({
                url: i,
                data: e,
                success: function(t) {
                    var e = t.data;
                    if (a.setData({
                        isLoadMore: !0
                    }), 1 === e.result) {
                        var i = e.data.data;
                        1 == a.data.activeName ? (a.setData({
                            fanList: a.data.fanList.concat(i)
                        }), console.log(a.data.fanList)) : a.setData({
                            attentionList: a.data.attentionList.concat(i)
                        });
                    } else a.setData({
                        page: a.data.page - 1,
                        isLoadMore: !1
                    }), wx.showToast({
                        title: e.msg,
                        icon: "none",
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    onShareTimeline: function() {}
});